var display_storage = new Array();
$(document).ready(function(){
    FB.api("/" + id_social_user + "?fields=name", function(data){
       var name = data.name;
       $("[name='fan-name']").each(function(){
           $(this).html(name);
       });
    });
       
    $(".fb-name").each(function(){
        var id_social = $(this).attr("id");
        FB.api("/" + id_social + "?fields=name", function(data) {
            var id_social = data.id;
            $(".fb-name[id='" + id_social + "']").html(data.name);
        });
    });
    
    $(".wrap-tab li").click(function(){
        $(".wrap-tab .active").removeClass("active");
        $(this).addClass("active");
        offset = 0;
        viewMoreAction();
    });
});

function viewMoreAction() {
    $(".display-actions").html("");
    $(".loader").css("display", "block");
    var action_type = $("li[class='active']").attr("name");
    if (display_storage[action_type] != null) {
        $(".display-actions").html(display_storage[action_type]);
        $(".loader").css("display", "none");
    } else {
        $.ajax({
            url: base_url + "/ajax/index/getaction",
            data: {
                pid: id_social_page,
                uid: id_social_user,
                at: action_type,
                offset: offset,
                time: time
            },
            success:function(res){
                $(".display-actions").html(res);
                $(".loader").css("display", "none");
                display_storage[action_type] = res;
            }
        });
    }
}